package castledefense.data;

import com.badlogic.gdx.graphics.Texture;

import castledefense.logic.Map;
import castledefense.logic.buildings.Building;
import castledefense.logic.buildings.EnemyBase;
import castledefense.logic.buildings.Tower1;
import castledefense.logic.buildings.Tower2;

public class BuildingData {
	public static final int maxUpgrades = 5;
	public static final int tower2TargetMax = 4;

	public static final int fireUpgradeCost = 10;
	public static final int waterUpgradeCost = 10;
	public static final int earthUpgradeCost = 10;
	public static final int airUpgradeCost = 10;

	public static final int destroy = -2;
	public static final int noBuilding = -1;
	public static final int castle = 0;
	public static final int tower1 = 1;
	public static final int wall = 2;
	public static final int tower2 = 5;
	public static final int enemyBase = 6;

	public static int building = noBuilding;

	public static int money = 40;
	public static int moneyGeneration = 2;

	public static final int tower1Cost = 5;
	public static final int tower2Cost = 10;

	public static int getCost(int type) {
		switch (type) {
		case (tower1):
			return tower1Cost;
		case (tower2):
			return tower2Cost;
		}

		return 0;
	}

	public static int getUpgradeCost(int type, int level) {
		switch (type) {
		case (GameData.fire):
			return fireUpgradeCost << level;
		case (GameData.water):
			return waterUpgradeCost << level;
		case (GameData.earth):
			return earthUpgradeCost << level;
		case (GameData.air):
			return airUpgradeCost << level;
		}

		return 0;
	}

	public static int getSize(int type) {
		switch (type) {
		case (castle):
			return 5;
		case (tower1):
			return 2;
		case (tower2):
			return 2;
		case (enemyBase):
			return 4;
		}

		return 0;
	}

	public static Building getBuilding(Map map, int x, int y, int type) {
		switch (type) {
		case (castle):
			return null;
		case (tower1):
			return new Tower1(map, x, y, type);
		case (tower2):
			return new Tower2(map, x, y, type);
		case (enemyBase):
			return new EnemyBase(map, x, y, type, GameData.noElement);
		}
		return null;
	}

	public static final double getUpgradeLevelValue(int type, int level) {
		level--;
		switch (type) {
		case (GameData.fire):
			return 1.5 * (double) (level * 1.5);
		case (GameData.water):
			return 0.25 + (double) level * 0.1;
		case (GameData.earth):
			return 0.25 + (double) level * 0.1;
		case (GameData.air):
			return 3 << level;
		case (GameData.air + 1):
			return 2 << level;
		case (GameData.air + 2):
			return 1 << level;
		}
		return 1;
	}

	public static final int getUpgradeLevelDuration(int type, int level) {
		level--;

		switch (type) {
		case (GameData.fire):
			return 5000 + level * 2000;
		case (GameData.water):
			return 5000 + level * 1000;
		case (GameData.earth):
			return 500 + level * 100;
		case (GameData.air):
			return 1;
		}

		return 0;
	}

	public static Texture getTexture(int type, int elementType) {
		switch (type) {
		case (castle):
			return Resources.castleIm;
		case (tower1):
			return Resources.towerIm;
		case (tower2):
			return Resources.tower2Im;
		case (enemyBase):
			return Resources.fireBaseIm;
		case (wall):
			return Resources.gateEarthIm;
		default:
			return null;

		}
	}
}
